{# 继承模板页面 #}

{% extends "news/base.html" %}

{% block title %}
    新闻详情页
{% endblock %}

{% block scriptBlock %}
    <script type="text/javascript" src="../../static/news/js/detail.js"></script>
{#{% endblock %}#}
{##}
{#{% block heads %}#}

{% endblock %}

{% block left_contents %}
    <div class="detail_con fl">
            <h3>{{ news.title }}</h3>
            <div class="detail_about clearfix">
                <span class="time_souce fl">{{ news.create_time }} 来源: {{ news.source }}</span>
                <span class="comment fr">{{ news.clicks }}</span>
            </div>

            <p class="summary">
                {{ news.digest }}
            </p>
{# 使用安全模式 #}
            {{ news.content |safe }}
    {% if not is_collect %}
        <a href="javascript:;" class="collection block-center" data-newid="{{ news.id }}">收藏</a>
        <a href="javascript:;" class="collected block-center" data-newid="{{ news.id }}" style="display: none"><span class="out">已收藏</span><span class="over">取消收藏</span></a>
    {% else %}
        <a href="javascript:;" class="collection block-center" data-newid="{{ news.id }}" style="display: none">收藏</a>
        <a href="javascript:;" class="collected block-center" data-newid="{{ news.id }}"><span class="out">已收藏</span><span class="over">取消收藏</span></a>
    {% endif %}

{#判断，如果用的未登陆状态，显示下面的，如果登陆则小时#}
    {% if not user %}
        <div class="comment_form_logout">
            登录发表你的评论
        </div>
    {% else %}
        <form action="" class="comment_form" data-newsid="{{ news.id }}">
            <div class="person_pic">
                {% if user.avatar_url %}
                        <img src="{{ user.avatar_url }}" alt="用户图标">
                    {% else %}
                        <img src="../../static/news/images/cat.jpg" alt="用户图标">
                    {% endif %}
            </div>
            <textarea placeholder="请发表您的评论" class="comment_input"></textarea>
            <input type="submit" name="" value="评 论" class="comment_sub">
        </form>

    {% endif %}


        <div class="comment_count">
{#            {{ total_comment }}条评论#}
{#     不再通过从后台获取数据了。直接由前端做到。获取评论的条数并显示       #}
        </div>

{#  评论信息      #}
        <div class="comment_list_con">
            {% for comment in comments %}
                <div class="comment_list">
                <div class="person_pic fl">
                    {% if comment.avatar_url %}
                        <img src="{{ comment.avatar_url }}" alt="用户图标">
                    {% else %}
                        <img src="../../static/news/images/worm.jpg" alt="用户图标">
                    {% endif %}

                </div>
                <div class="user_name fl">{{ user.nick_name }}</div>
                <div class="comment_text fl">
                    {{ comment.content }}
                </div>
                {% if comment.parent %}
                <div class="reply_text_con fl">
                    <div class="user_name2">{{ comment.parent.user.nick_name }}</div>
                    <div class="reply_text">
                        {{ comment.parent.content }}
                    </div>
                </div>
                {% endif %}

                <div class="comment_time fl">{{ comment.create_time }}</div>
                {% if comments %}

                {% endif %}
                <a href="javascript:;" class="comment_up  {% if comment.is_like %}has_comment_up{% endif %} fr" data-commentid="{{ comment.id }}" data-newsid="{{ comment.news_id }}" data-likecount="{{ comment.like_count }}"> 赞 {{ comment.like_count }}</a>
                <a href="javascript:;" class="comment_reply fr">回复</a>
                <from class="reply_form fl" data-commentid="{{ comment.id }}" data-newsid="{{ comment.news_id }}">
                    <textarea  class="reply_input"></textarea>
                    <input type="submit" name="" value="回复" class="reply_sub fr">
                    <input type="reset" name="" value="取消" class="reply_cancel fr">
                </from>
            </div>
            {% endfor %}


        </div>


        </div>
{% endblock %}

{% block right_content %}
    <div class="rank_con fr">
{#  右侧的用户登陆状态  #}
        {% if user %}
            <div class="author_card">
                {% if user.avatar_url %}
                <a href="#" class="author_pic"><img src="{{ user.avatar_url }}" alt="author_pic"></a>
                {% else %}
                <a href="#" class="author_pic"><img src="../../static/news/images/user_pic.png" alt="author_pic"></a>
                {% endif %}

                <a href="#" class="author_name">{{ user.nick_name }}</a>
                <div class="author_resume">{{ user.signature }}</div>
                <div class="writings"><span>总篇数</span><b>{{ news_count }}</b></div>
                <div class="follows"><span>粉丝</span><b>{{ followers_count }}</b></div>
                <a href="javascript:;" class="focus fr" data-userid="{{ user.id }}">关注</a>
                <a href="javascript:;" class="focused fr" data-userid="{{ user.id }}"><span class="out">已关注</span><span class="over">取消关注</span></a>
            </div>
        {% endif %}


            <div class="rank_title">
                <h3>点击排行</h3>
            </div>
            <ul class="rank_list">
{#     最新的新闻，显示在下面          #}
                {% if hot_news_list %}
                    {% for hot_news in hot_news_list %}
                        <li><span class="{{ loop.index | rank }}">{{ loop.index }}</span><a href="/news/{{ hot_news.id }}">{{ hot_news.title }}</a></li>
                    {% endfor %}

                {% endif %}
{#                <li><span class="first">1</span><a href="#">势如破竹！人民币再度连闯四道关口 在岸、离岸双双升破6.42</a></li>#}
{#                <li><span class="second">2</span><a href="#">凛冬已至，还有多少银行人在假装干银行</a></li>#}
{#                <li><span class="third">3</span><a href="#">人民日报：部分城市楼市放松限制引关注，楼市调控不会“拉抽屉”</a></li>#}
{#                <li><span>4</span><a href="#">势如破竹！人民币再度连闯四道关口 在岸、离岸双双升破6.42</a></li>#}
{#                <li><span>5</span><a href="#">凛冬已至，还有多少银行人在假装干银行</a></li>#}
{#                <li><span>6</span><a href="#">人民日报：部分城市楼市放松限制引关注，楼市调控不会“拉抽屉”</a></li>#}
            </ul>
        </div>
{% endblock %}
